var RenYuan = new Vue({

    el : '#JingshangRenyuanlist',
    data :{

        danweiid:'',
        truename:'',
        renyuanleibie:'',
        shuliang:'',
        renyuan : {},
        jingshang:{},
        renyuanlist : [],
        jingshangqingkuanglist:[],
        renyuanleibielist:[],
        danweinamelist:[],


        editFlag : 0,					// 0:新增，1：修改
        show : false,					// 显示列表是否有数据
        jingshangqingkuang: false,

        pageIndex : 1,
        pageSize :6,
        pageCount : 0,
        recordCount : 0,
        inputPageIndexValue : "",


    },
    created : function() {

        this.findVaild('0',0);
        this.selectDepNameByValid();
        this.initDict();


    },
    methods : {

        // 绑定字典表
        initDict : function() {
            var _this = this;

            // 人员类别
            $.post("../dict_renyuanleibie/find_valid", {
                rdm : Math.random()
            }, function (ppData) {
                if (ppData != null) {
                    if (ppData.result == '1') {
                        var data = ppData.resultContent;
                        _this.renyuanleibielist = data;
                    } else {
                        layer.alert(ppData.message);
                    }
                }
            }, "json");
        },

        selectDepNameByValid : function() {
            var _this = this;

            // 单位名称
            $.post("../dept/findcengji_by_deptid", {
                deptid: 0,
                rdm : Math.random()
            }, function (ppData) {
                if (ppData != null) {
                    if (ppData.result == '1') {
                        var data = ppData.resultContent;
                        _this.danweinamelist = data;
                    } else {
                        layer.alert(ppData.message);
                    }
                }
            }, "json");
        },

        findVaild: function(ppPaixu,ppFlag){
            var _this = this;
            if (ppFlag==1){
                _this.pageIndex=1;
            }
            $("#name").removeClass("xuanzhong");
            $("#namedesc").removeClass("xuanzhong");
            $("#renyuanleibie").removeClass("xuanzhong");
            $("#renyuanleibiedesc").removeClass("xuanzhong");
            $("#junxianleibie").removeClass("xuanzhong");
            $("#junxianleibiedesc").removeClass("xuanzhong");
            $("#jigoumingchengma").removeClass("xuanzhong");
            $("#jigoumingchengmadesc").removeClass("xuanzhong");
            layer.open({type:3});
            if (ppPaixu!=0) {

                $("#"+ppPaixu).addClass("xuanzhong");
            }

            $.post("../renyuan/find_custom_by_Valid",{
                deptid : _this.danweiid,
                truename: _this.truename,
                renyuanleibie: _this.renyuanleibie,
                shuliang:_this.shuliang,
                paixu:ppPaixu,
                pageindex : _this.pageIndex,
                pagesize : _this.pageSize,
                rdm : Math.random()
            },function(ppData){
                layer.closeAll("loading");
                if (ppData != null){
                    if(ppData.result == "1"){
                        var data=ppData.resultContent;

                        if(data.RenyuanList.length > 0){
                            _this.show = true;
                            _this.renyuanlist=data.RenyuanList;

                            var PageInfo = data.PageInfo;
                            _this.pageIndex = PageInfo.pageIndex;
                            _this.recordCount = PageInfo.recordCount;
                            _this.pageCount = PageInfo.pageCount;

                        }else {
                            _this.show = false;
                        }

                    }else{
                        layer.alert(ppData.message);
                    }
                }

            },"json");
        },

        findByRenyuanId: function(ppRenyuanId){
            xadmin.open('博士后状态修改','../jingshangqingkuang/detail_jingshang.html?renyuanId='+ppRenyuanId,false,false,true);
        },

        modify : function(){

            var _this = this;
            _this.renyuanlist="";
            _this.jingshangqingkuanglist="";
            $("#zhuangtaiModal").modal();
            this.editFlag = 0;
            $("#zhuangtaiModal").html("状态修改");


        },
        ShowJingshang:function (){
            $("#jingfeiModal").modal();
        },

        bindjingshang :function(ppJingshangqingkuang){
            $("#jingshangDetailModal").modal();
            $("#myModalLabel").html(ppJingshangqingkuang.NAME+"经商办企业信息详情");
            var _this = this;
            _this.jingshang = ppJingshangqingkuang;

        },


        //跳到首页
        SetPageIndex : function(){
            this.pageIndex = 1;
        },
        SetPageEnd : function(){
            this.pageIndex = this.pageCount;
        },
        //上一页
        SetPageIndexPrePage : function(){
            var PrePage = ((this.pageIndex -1) <= 0) ? 1 : (this.pageIndex -1);
            this.pageIndex = PrePage;
        },
        //下一页
        SetPageIndexNextPage : function(){
            var NextPage = ((this.pageIndex +1) >= this.pageCount) ? this.pageCount : (this.pageIndex +1);
            this.pageIndex = NextPage;
        },
        //跳转界面
        JumpPage : function(){
            if(this.inputPageIndexValue <= 1){
                this.inputPageIndexValue = 1;
            }else if(this.inputPageIndexValue >= this.pageCount){
                this.inputPageIndexValue = this.pageCount;
            }
            this.pageIndex = this.inputPageIndexValue;
            this.inputPageIndexValue = '';
        },




    },
    watch :{
        //监控分页情况，刷新列表
        pageIndex : function(){

            this.findVaild('0',0);
        }
    }

});
